How to use the converter utility

This tool converts the input internally calibrated mean spectra from the continuous representation to a sampled form.

Information about the units of the variables used in this tutorial can be found here.

Basic usage

The converter returns two different outputs:

  1. The values for all sampled spectra as a pandas DataFrame.
  2. The sampling used to convert the input spectra in pseudo-wavelength. This sampling should be an iterable (e.g. a NumPy array), the minimum accepted value is -10 and the maximum is 70. The default sampling is numpy.linspace(0, 60, 600).

Input types

The input does not have to be a path to a file. There are other options: a pandas DataFrame, an ADQL query or a list of sourceIds.

Passing a DataFrame

Running a query

The converter can also take the parameters 'username' and 'password' for Cosmos credentials, instead of using the interactive login (like in the example below). See that information here.

Passing a list

A list of sourceIds can be passed to the converter as the first argument. The converter will then query the Archive for these objects.

The converter can also take the parameters 'username' and 'password' for Cosmos credentials, instead of using the interactive login (like in the example below). See that information here.

Advanced usage

Additional arguments can be passed to the converter.

These are:

  1. sampling
  2. truncation
  3. output_path
  4. output_file
  5. output_format
  6. save_file

Sampling

A custom sampling can be passed to the function. This sampling should be an iterable (list, tuple, generator, or preferably a NumPy array). If no sampling is given, the default sampling is returned.

The default sampling of the converter corresponds to numpy.linspace(0., 60., 600.) in pseudo-wavelength.

The minimum value allowed in the sampling is -10, and the maximum is 70. The program will raise an error is the sampling does not comply.

The results can be plotted using the plotter utility.

The figure can be saved too.

Truncation

The source mean BP/RP spectrum is described as a combination of basis functions. Particularly for faint sources or sources with a low number of observations, it is useful to represent the spectrum using a smaller set of basis functions to avoid higher-order bases fitting the noise in the observed data.

The truncation parameter is a boolean which toggles the truncation of the set of bases.

We can use GaiaXPy's plot spectra utility to see the differences in the results.

The differences between the truncated and not truncated versions are too small to be seen in the previous plot. But we can compare the values.

Output_path, output_file, output_format, save_file

Three parameters: output_path, output_file, and output_format define the entire path of the resulting file.

The default output path is the current path. If the given output path does not exist, it will be created.

The default output file name is 'output_spectra'.

The default output format is the format of the input file (i.e. if the input file is a 'fits', then the output file will be a FITS file by default.), or CSV in any other case (DataFrame, ADQL query or list).

NOTE: If a file with the same path and name already exists, it will be AUTOMATICALLY OVERWRITTEN.

The additional parameter save_file is a boolean that tells the program whether to save the results or not. If 'output_file' is given but 'save_file' is set to False, a warning will be raised.